<template>
  <div class="pagestyle">
    <list_controller ref="zujianname" :options="state.options">
      <template v-slot:opraCurdBtnlist="row">
        <span>
          <el-button
            class="tableFontSize"
            type="primary"
            link
            size="small"
            @click="moniBtn(row.row.row)"
            >模拟场景</el-button
          >
        </span>
      </template>
      <template v-slot:opraCurdBtnAll>
        <!-- v-if="userStore.modify" -->
        <span :class="'listInfoBtn'" @click="deleteBtn('mul')">
          <svg-icon class-name="search-icon" icon-class="shanchu" />
          删除
        </span>
      </template>
      <template v-slot:selectNamelist> 钻场总览 </template>
    </list_controller>
  </div>
</template>
<script setup>
import list_controller from "@/components/commonCom/list_controllerChoucai";
import { computed, onMounted, reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { table_headers } from "@/components/commonCom/table_headersChoucai";
import axios from "@/utils/request";
import usePagesStore from "@/store/modules/pages";
import { getsubstationmodel, fileupload } from "@/api/config";
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
const store = usePagesStore();
const router = useRouter();
let previewHttps = import.meta.env.VITE_APP_HTTP;
components: {
  list_controller;
}
const upload = ref(null);
let state = reactive({
  options: {
    tableheads: computed(() => table_headers.DrainageDrillSite),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "workingFaceIds",
          title: "工作面名称",
          type: "select",
          binddata: "",
          options: [],
        },
        {
          field: "statusId",
          title: "状态",
          type: "select",
          binddata: "",
          options: [],
        },
        {
          field: "standardStatus",
          title: "达标情况",
          type: "select",
          binddata: "",
          options: [
            { label: "已达标", value: 1 },
            { label: "未达标", value: 0 },
          ],
        },
      ],
      queryMap: new Map([
        // ['sensorTypeId', 'safety_pointType'],
        // ['deviceTypeId', 'safety_deviceType'],
        // ['alarmTypeId', 'alarmType']
      ]),
    },
    dataUrl: "/drainage/drill-site/page",
    delUrl: "/drainage/drill-site/delete",
    addUrl: "/drainage/drill-site/insert",
    descUrl: "/drainage/drill-site/",
    editUrl: "/drainage/drill-site/update",
  },
});
// 模拟场景
const moniBtn = (row) => {};
function deleteBtn(row) {
  let ids = [];
  if (row != "mul") {
    ids = [row.id];
  } else {
    if (store.records.length > 0) {
      ids = store.records.map((item) => {
        return item.id;
      });
    } else {
      proxy.$modal.msgSuccess("请先勾选所要删除数据!");
    }
  }
  if (ids.length > 0) {
    ElMessageBox.confirm("确定要删除该数据吗?", "温馨提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(() => {
        axios.post(state.options.delUrl, ids).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            ElMessage({
              type: "success",
              message: res.msg,
            });
            store.records = [];
          }
        });
      })
      .catch(() => {
        ElMessage({
          type: "info",
          message: "删除取消",
        });
      });
  }
}

function getSelectData() {
  axios
    .post("/gas-drainage/system/dict/data/type-batch", ["drill_site_status"])
    .then((res) => {
      state.options.queryList.querys[1].options =
        res.data.drill_site_status.map((item) => {
          //钻场状态
          return {
            label: item.dictLabel,
            value: Number(item.dictValue),
          };
        });
    });
  axios.post("/drainage/working-face/list", {}).then((res) => {
    state.options.queryList.querys[0].options = res.data.map((item) => {
      return {
        label: item.name,
        value: item.id,
      };
    });
  });
}
onMounted(() => {
  getSelectData();
});
</script>
<style lang="scss" scoped>
</style>